package com.czl.elm.util;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;

public class FileUtil {
    public static boolean imgCheck(String filetype){

        if(!filetype.equalsIgnoreCase("jpg")&&!filetype.equalsIgnoreCase("png")&&!filetype.equalsIgnoreCase("jpeg")){
            return false;
        }
        return true;
    }

    public static String getFileType(String file){
        return file.split("\\.")[1];
    }
    public static Boolean fileUpload(MultipartFile profile,File dest, String path){
        if (!dest.getParentFile().exists()) {
            dest.getParentFile().mkdirs();
        }
        try {
            profile.transferTo(dest);
        } catch (Exception e) {
            return false;
        }
        return true;
    }
}
